
#include "unp.h"


void internet_to_host_test();
void GetServerAddressInformationTest();
void TcpConnectTest();

// build command
// gcc -Wall -Wshadow -g unp_test.c -o test -I./
int main(int argc, char * argv[]) {

    // 函数测试 
    internet_to_host_test();
    GetServerAddressInformationTest();
    return EXIT_SUCCESS;
}

void internet_to_host_test() {

    const char * ip = "127.0.0.1";
    struct sockaddr_in sai;
    bzero(&sai, sizeof(sai));

    sai.sin_family = AF_INET;
    inet_pton(sai.sin_family, ip, &sai.sin_addr);

    char buffer[100];
    printf("%s\n",InternetToHost(&sai, buffer, 100));
}

void GetServerAddressInformationTest() {

    const char * host    = "www.baidu.com";
    const char * service = "443";     
    printf("result=%d\n",GetServerAddressInformation(host, service));
}

void TcpConnectTest() {

    // 
}

